***This is the code used to create the variables in the analysis in Tables 2 & 3 and Figures 1 & 2 & 3***

**creating experimental condition**
gen ExperimentalCondition = P_EXP
label variable ExperimentalCondition "ExperimentalCondition"
label define ExperimentalCondition_lbl 1 "Control" 2 "Treatment", modify
label values ExperimentalCondition ExperimentalCondition_lbl  
tab ExperimentalCondition

**creating control and treatment variables**
gen Control = .
replace Control = 1 if ExperimentalCondition == 1
replace Control = 0 if ExperimentalCondition == 2

gen Treatment = .
replace Treatment = 1 if ExperimentalCondition == 2
replace Treatment = 0 if ExperimentalCondition == 1


**create facemasks**
gen facemasks = .
label variable facemasks "facemasks"
label define facemasks_lbl 1 "Not at all Important"  0 "Extremely Important", modify
label values facemasks facemasks_lbl
replace facemasks = 1 if Q20==5
replace facemasks = .75 if Q20==4
replace facemasks = .5 if Q20==3
replace facemasks = .25 if Q20==2
replace facemasks = 0 if Q20==1
replace facemasks = . if Q20==98


**create facemasks dichotomous**
gen facemasks_dichotomous = .
label variable facemasks_dichotomous "facemasks_dichotomous"
label define facemasks_dichotomous_lbl 1 " Not Important" 0 "Important", modify
label values facemasks_dichotomous facemasks_dichotomous_lbl
replace facemasks_dichotomous = 1 if Q20 == 3 | Q20 == 4 | Q20==5
replace facemasks_dichotomous = 0 if Q20 == 1 | Q20 == 2


** create individualrights**
gen individualrights = .
label variable individualrights "individualrights"
label define individualrights_lbl 1 "Strongly Agree" 0 "Strongly Disagree", modify
label values individualrights individualrights_lbl
replace individualrights = 1 if Q16==1
replace individualrights = .75 if Q16==2
replace individualrights = .5 if Q16==3
replace individualrights = .25 if Q16==4
replace individualrights = 0 if Q16==5
replace individualrights = . if Q16==98

** create individual rights dichotomous**
gen individualrights_dichotomous = .
label variable individualrights_dichotomous "individualrights_dichotomous"
label define individualrights_dichotomous_lbl 1 "Agree" 0 "Disagree", modify
label values individualrights_dichotomous individualrights_dichotomous_lbl
replace individualrights_dichotomous = 1 if Q16 == 1 | Q16 == 2
replace individualrights_dichotomous = 0 if Q16 == 4 | Q16 == 5|Q16 == 3

** create visitparks**
gen visitparks = .
label variable visitparks "visitparks"
label define visitparks_lbl 1 "Allowed Without Any Restrictions" 0 "Complete Restrictions", modify
label values visitparks visitparks_lbl
replace visitparks = 1 if Q23A==1
replace visitparks = .5 if Q23A==2
replace visitparks = 0 if Q23A==3 


** create visitparks_dichotomous**
gen visitparks_dichotomous = .
label variable visitparks_dichotomous "visitparks_dichotomous"
label define visitparks_dichotomous_lbl 1 "Allowed Without Any Restrictions" 0 "Some or Complete Restrictions", modify
label values visitparks_dichotomous visitparks_dichotomous_lbl
replace visitparks_dichotomous = 1 if Q23A == 1 
replace visitparks_dichotomous =0 if Q23A== 2 | Q23A == 3
replace visitparks_dichotomous = . if Q23A==98

*create Follow_Blacks** 
gen Follow_Blacks = .
label variable Follow_Blacks "Follow_Blacks"
label define Follow_Blacks_lbl 1 "Never" 0 "Always", modify
label values Follow_Blacks Follow_Blacks_lbl
replace Follow_Blacks = 1 if Q22A==5
replace Follow_Blacks = .75 if Q22A==4
replace Follow_Blacks = .5 if Q22A==3
replace Follow_Blacks = .25 if Q22A ==2
replace Follow_Blacks = 0 if Q22A==1

**create Follow_Blacks_dichotomous**
gen Follow_Blacks_dichotomous = .
label variable Follow_Blacks_dichotomous "Follow_Blacks_dichotomous"
label define Follow_Blacks_dichotomous_lbl 1 "Never, Some, Half" 0 "Most of the Time, Always", modify
label values Follow_Blacks_dichotomous Follow_Blacks_dichotomous_lbl
replace Follow_Blacks_dichotomous = 0 if Q22A == 1 | Q22A ==2
replace Follow_Blacks_dichotomous = 1 if Q22A == 3 | Q22A ==4 | Q22A == 5




** create hardworkWhites**
gen hardworkWhites = .
label variable hardworkWhites "whites hardworking"
label define hardworkWhites_lbl 0 "Harworking" 1 "Lazy", modify
label values hardworkWhites hardworkWhites_lbl  
replace hardworkWhites =0 if Q6 == 7
replace hardworkWhites = .16666667 if Q6 == 6
replace hardworkWhites = .3333333 if Q6 == 5
replace hardworkWhites = .5 if Q6 == 4
replace hardworkWhites = .6666667 if Q6 == 3
replace hardworkWhites = .8333333 if Q6 == 2
replace hardworkWhites = 1 if Q6 == 1

** create hardworkBlacks**
gen hardworkBlacks = .
label variable hardworkBlacks "blacks hardworking"
label define hardworkBlacks_lbl 0 "Harworking" 1 "Lazy", modify
label values hardworkBlacks hardworkBlacks_lbl 
replace hardworkBlacks =0 if Q5 == 7
replace hardworkBlacks = .16666667 if Q5 == 6
replace hardworkBlacks = .3333333 if Q5 == 5
replace hardworkBlacks = .5 if Q5 == 4
replace hardworkBlacks = .6666667 if Q5 == 3
replace hardworkBlacks = .8333333 if Q5 == 2
replace hardworkBlacks = 1 if Q5 == 1


**create lazystereotype2**
gen lazystereotype = hardworkWhites - hardworkBlacks
tab lazystereotype
generate lazystereotype2 = lazystereotype
replace lazystereotype2 = 1 if lazystereotype < 0
replace lazystereotype2  = 0 if lazystereotype >=0
tab lazystereotype2

**create intelligentWhites**
gen intelligentWhites = .
label variable intelligentWhites "whites intelligent"
label define intelligentWhites_lbl 0 "Intelligent" 1 "Unintelligent", modify
label values intelligentWhites intelligentsWhites_lbl
replace intelligentWhites = 0 if Q8==7
replace intelligentWhites = .16666667 if Q8 ==6
replace intelligentWhites = .3333333 if Q8 ==5
replace intelligentWhites =.5 if Q8 ==4
replace intelligentWhites =.6666667 if Q8==3
replace intelligentWhites =.8333333 if Q8==2
replace intelligentWhites = 1 if Q8==1
summarize Q8
summarize intelligentWhites

**create intelligentBlacks**
gen intelligentBlacks = .
label variable intelligentBlacks "blacks intelligent"
label define intelligentBlacks_lbl 0 "Intelligent" 1 "Unintelligent", modify
label values intelligentBlacks intelligentBlacks_lbl
replace intelligentBlacks =Q7
tab Q7
replace intelligentBlacks = 0 if Q7==7
replace intelligentBlacks = .16666667 if Q7 ==6
replace intelligentBlacks = .3333333 if Q7 ==5
replace intelligentBlacks =.5 if Q7 ==4
replace intelligentBlacks =.6666667 if Q7==3
replace intelligentBlacks =.8333333 if Q7==2
replace intelligentBlacks = 1 if Q7==1
summarize Q7
summarize intelligentBlacks


**create unintelligentstereotype2**
generate unintelligentstereotype = intelligentWhites - intelligentBlacks
tab unintelligentstereotype

generate unintelligentstereotype2 = unintelligentstereotype
replace unintelligentstereotype2 = 1 if unintelligentstereotype< 0
replace unintelligentstereotype2 = 0 if unintelligentstereotype >= 0

***Create negstereotpe_endorsement ---This is the variable that will be used as the dummy variable in the interactions with the treatments***
generate negstereotype_endorsement = (unintelligentstereotype2 + lazystereotype2)/2
summarize negstereotype_endorsement
label variable negstereotype_endorsement "negative stereotype endorsement"
label define negstereotype_endorsement 0 "did not endorse stereotypes"  1 "endorsed stereotypes", modify
label values negstereotype_endorsement negstereotype_endorsement_lbl




****This is the code used to create the variables in Figure A1

gen gender_new = GENDER
replace gender_new = ((GENDER-1)) if GENDER<98
label define gender_lbl 1 "Female" 0 "Male"
label values gender_new gender_lbl  
tab gender_new

gen pid7 = P_PARTYID7
replace pid7 = ((P_PARTYID7-1)/6) if P_PARTYID7<98
label define pid7_lbl 1 "Strong Republican" 0 "Strong Democrat"
label values pid7 pid7_lbl  
tab pid7

gen ideo5 = P_IDEO
replace ideo5 = . if P_IDEO == 8
replace ideo5 = ((P_IDEO-1)/6) if P_IDEO<8
label define ideo5_lbl 1 "Extrememly Conservative" 0 "Extrememly Liberal"
label values ideo5 ideo5_lbl  
tab ideo5

gen South = REGION4
replace South = 1 if REGION4 == 3
replace South = 0 if REGION4 == 1
replace South = 0 if REGION4 == 2
replace South = 0 if REGION4 == 4

gen educ = EDUC4
replace educ = ((EDUC4-1)/3) if EDUC4<8
label define educ_lbl 1 "Bachelors Degree or Higher" 0 "No HS diploma"
label values educ educ_lbl  
tab educ

generate statemention = 0
replace statemention = 1 if STATE=="NY"
tab STATE
replace statemention = 1 if STATE=="LA"
replace statemention = 1 if STATE=="MI"
replace statemention = 1 if STATE=="IL"

